home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / tex / texdr179.lzh / texdraw / epic / epic.sty next >
Text File  |  1991-02-06  |  27KB  |  557 lines

  1. \makeatletter
  2. \typeout{%
  3. Enhancements to Picture Environment. Version 1.2 - Released June 1, 1986}
  4. %----------------------------------------------------------------------
  5. % Copyright (C) podar@sbcs (Sunil Podar) July 14,1986.
  6. % You may use this file in whatever way you wish. You are requested to
  7. % leave this notice intact, and report any bugs, enhancements, comments,
  8. % suggestions, etc. to:
  9. % USmail: Sunil Podar,Dept. of Computer Science,SUNY at Stony Brook,NY 11794.
  10. %  CSNET: podar@sbcs.csnet
  11. %   ARPA: podar%suny-sb.csnet@csnet-relay.arpa
  12. %   UUCP: {allegra, hocsd, philabs, ogcvax}!sbcs!podar
  13. %----------------------------------------------------------------------
  14. % This file contains implementation of:
  15. % \multiputlist \matrixput      \grid           \picsquare
  16. % \dottedline   \dashline       \drawline       \jput
  17. % \putfile
  18. % Environments: dottedjoin, dashjoin and drawjoin
  19. %
  20. % For documentation, see the accompanying manual.
  21. %----------------------------------------------------------------------
  22. % usage: \multiputlist(x,y)(delta-x,delta-y)[tbrl]{item1,item2,item3,.....}
  23. % \lop and \lopoff taken from TeXbook.
  24. %----------------------------------------------------------------------
  25. \def\lop#1\to#2{\expandafter\lopoff#1\lopoff#1#2}
  26. \long\def\lopoff,#1,#2\lopoff#3#4{\def#4{#1}\def#3{,#2}}
  27. \def\@@mlistempty{,}
  28. \newif\iflistnonempty
  29. \def\multiputlist(#1,#2)(#3,#4){\@ifnextchar
  30. [{\@imultiputlist(#1,#2)(#3,#4)}{\@imultiputlist(#1,#2)(#3,#4)[]}}
  31.  
  32. \long\def\@imultiputlist(#1,#2)(#3,#4)[#5]#6{{%
  33. \@xdim=#1\unitlength \@ydim=#2\unitlength
  34. \listnonemptytrue \def\@@mlist{,#6,} % need this for end condition
  35. \loop
  36. \lop\@@mlist\to\@@firstoflist
  37. \@killglue\raise\@ydim\hbox to\z@{\hskip
  38. \@xdim\@imakepicbox(0,0)[#5]{\@@firstoflist}\hss}
  39. \advance\@xdim #3\unitlength\advance\@ydim #4\unitlength
  40. \ifx\@@mlist\@@mlistempty \listnonemptyfalse\fi
  41. \iflistnonempty
  42. \repeat\relax
  43. \ignorespaces}}
  44. %----------------------------------------------------------------------
  45. % two-dimensional version of \multiput
  46. % \matrixput(0,0)(20,0){5}(0,20){3}{\circle{2}}
  47. %----------------------------------------------------------------------
  48. \newcount\@@multicnt
  49. \def\matrixput(#1,#2)(#3,#4)#5(#6,#7)#8#9{%
  50. \ifnum#5>#8\@matrixput(#1,#2)(#3,#4){#5}(#6,#7){#8}{#9}%
  51. \else\@matrixput(#1,#2)(#6,#7){#8}(#3,#4){#5}{#9}\fi}
  52.  
  53. %% here #5 >= #8
  54. \long\def\@matrixput(#1,#2)(#3,#4)#5(#6,#7)#8#9{{\@killglue%
  55. \@multicnt=#5\relax\@@multicnt=#8\relax%
  56. \@xdim=0pt%
  57. \@ydim=0pt%
  58. \setbox\@tempboxa\hbox{\@whilenum \@multicnt > 0\do {%
  59. %%\typeout{\the\@multicnt, \the\@@multicnt}%
  60. \raise\@ydim\hbox to \z@{\hskip\@xdim #9\hss}%
  61. \advance\@multicnt \m@ne%
  62. \advance\@xdim #3\unitlength\advance\@ydim #4\unitlength}}%
  63. \@xdim=#1\unitlength%
  64. \@ydim=#2\unitlength%
  65. \@whilenum \@@multicnt > 0\do {%
  66. \raise\@ydim\hbox to \z@{\hskip\@xdim \copy\@tempboxa\hss}%
  67. \advance\@@multicnt \m@ne%
  68. \advance\@xdim #6\unitlength\advance\@ydim #7\unitlength}%
  69. \ignorespaces}}
  70. %----------------------------------------------------------------------
  71. %\grid(width,height)(delta-width,delta-height)[initial-X-integer,initial-Y-integer]
  72. % example: 1. \put(0,0){\grid(95,100)(9.5,10)}
  73. %          2. \put(0,0){\grid(100,100)(10,5)[-10,0]}
  74. %          or \put(0,0){\tiny \grid(100,100)(5,5)[0,0]}% numbers in \tiny font
  75. %----------------------------------------------------------------------
  76. \newcount\d@lta
  77. \newdimen\@delta
  78. \newdimen\@@delta
  79. \newcount\@gridcnt
  80. \def\grid(#1,#2)(#3,#4){\@ifnextchar [{\@igrid(#1,#2)(#3,#4)}%
  81. {\@igrid(#1,#2)(#3,#4)[@,@]}}
  82.  
  83. \long\def\@igrid(#1,#2)(#3,#4)[#5,#6]{%
  84. \makebox(#1,#2){%
  85. \@delta=#1pt\@@delta=#3pt\divide\@delta \@@delta\d@lta=\@delta%
  86. \advance\d@lta \@ne\relax\message{grid=\the\d@lta\space x}%
  87. %% copied the definition of \line(0,1){#2} for some efficiency!.
  88. \multiput(0,0)(#3,0){\d@lta}{\hbox to\z@{\hskip -\@halfwidth \vrule
  89.          \@width \@wholewidth \@height #2\unitlength \@depth \z@\hss}}%
  90. \ifx#5@\relax\else%
  91. \global\@gridcnt=#5%
  92. \multiput(0,0)(#3,0){\d@lta}{%
  93. \makebox(0,-2)[t]{\number\@gridcnt\global\advance\@gridcnt by #3}}%
  94. \global\@gridcnt=#5%
  95. \multiput(0,#2)(#3,0){\d@lta}{%
  96. \makebox(0,0)[b]{\number\@gridcnt\vspace{2mm}\global\advance\@gridcnt by #3}}%
  97. \fi%
  98. \@delta=#2pt\@@delta=#4pt\divide\@delta \@@delta\d@lta=\@delta%
  99. \advance\d@lta \@ne\relax\message{\the\d@lta . }%
  100. %% copied the definition of \line(1,0){#1} for some efficiency!.
  101. \multiput(0,0)(0,#4){\d@lta}{\vrule \@height \@halfwidth \@depth \@halfwidth
  102.          \@width #1\unitlength}%
  103. \ifx#6@\relax\else
  104. \global\@gridcnt=#6%
  105. \multiput(0,0)(0,#4){\d@lta}{%
  106. \makebox(0,0)[r]{\number\@gridcnt\ \global\advance\@gridcnt by #4}}%
  107. \global\@gridcnt=#6%
  108. \multiput(#1,0)(0,#4){\d@lta}{%
  109. \makebox(0,0)[l]{\ \number\@gridcnt\global\advance\@gridcnt by #4}}%
  110. \fi}}
  111. %----------------------------------------------------------------------
  112. % \picsquare is a centered square of dimensions governed by \thinlines,
  113. % \thicklines or \linethickness declarations.
  114. \def\picsquare{\hskip -0.5\@wholewidth%
  115. \vrule height \@halfwidth depth \@halfwidth width \@wholewidth}
  116. %
  117. % just a square dot with reference point at bottom-left
  118. \def\picsquare@bl{\vrule height \@wholewidth depth \z@  width \@wholewidth}
  119. %----------------------------------------------------------------------
  120. % \begin{dottedjoin}{interdot-gap in units}
  121. % .....
  122. % \end{dottedjoin}
  123. % \begin{dashjoin}{dash-length in units}{interdotgap in each dash}
  124. % .....
  125. % \end{dashjoin}
  126. % \begin{drawjoin}
  127. % .....
  128. % \end{drawjoin}
  129. % \jput(x,y){character}
  130. % \dottedline[opt. dotcharacter]{dotgap in units}(x1,y1)(x2,y2)...(xN,yN)
  131. % \dashline[#]{dash-length}[opt. dotgap](x1,y1)(x2,y2)...(xN,yN)
  132. % \drawline[#](x1,y1)(x2,y2)...(xN,yN)
  133. %----------------------------------------------------------------------
  134. % definitions for *join environment. had to do all this mess because of
  135. % optional arguments.
  136. %----------------------------------------------------------------------
  137. \newif\if@jointhem \global\@jointhemfalse
  138. \newif\if@firstpoint \global\@firstpointtrue
  139. \newcount\@joinkind
  140. %\newenvironment{dottedjoin}[1]%[opt char]{dotgap}
  141. %{\global\@jointhemtrue \gdef\dotgap@join{#1}\global\@joinkind=0\relax}%
  142. %{\global\@jointhemfalse \global\@firstpointtrue}
  143. %----------------------------------------------------------------------
  144. \def\dottedjoin{\global\@jointhemtrue \global\@joinkind=0\relax
  145.   \bgroup\@ifnextchar[{\@idottedjoin}{\@idottedjoin[\picsquare@bl]}}
  146. \def\@idottedjoin[#1]#2{\gdef\dotchar@join{#1}\gdef\dotgap@join{#2}}
  147. \def\enddottedjoin{\global\@jointhemfalse \global\@firstpointtrue\egroup}
  148. %----------------------------------------------------------------------
  149. \def\dashjoin{\global\@jointhemtrue \global\@joinkind=1\relax
  150.   \bgroup\@ifnextchar[{\@idashjoin}{\@idashjoin[\dashlinestretch]}}
  151. \def\@idashjoin[#1]#2{\edef\dashlinestretch{#1}\gdef\dashlen@join{#2}%
  152. \@ifnextchar[{\@iidashjoin}{\gdef\dotgap@join{}}}
  153. \def\@iidashjoin[#1]{\gdef\dotgap@join{#1}}
  154. \let\enddashjoin\enddottedjoin
  155. %----------------------------------------------------------------------
  156. \def\drawjoin{\global\@jointhemtrue \global\@joinkind=2\relax
  157.   \bgroup\@ifnextchar[{\@idrawjoin}{}}
  158. \def\@idrawjoin[#1]{\def\drawlinestretch{#1}}
  159. \let\enddrawjoin\enddottedjoin
  160. %----------------------------------------------------------------------
  161. %% this is equiv to \put(x,y){#1} when not in {dot*join} environment.
  162. \long\def\jput(#1,#2)#3{{\@killglue\raise#2\unitlength\hbox to \z@{\hskip
  163. #1\unitlength #3\hss}\ignorespaces}
  164. \if@jointhem
  165.  \if@firstpoint \gdef\x@one{#1} \gdef\y@one{#2} \global\@firstpointfalse
  166.  \else\ifcase\@joinkind
  167.                 \@dottedline[\dotchar@join]{\dotgap@join\unitlength}%
  168. (\x@one\unitlength,\y@one\unitlength)(#1\unitlength,#2\unitlength)
  169.                 \or\@dashline[\dashlinestretch]{\dashlen@join}[\dotgap@join]%
  170. (\x@one,\y@one)(#1,#2)
  171.                 \else\@drawline[\drawlinestretch](\x@one,\y@one)(#1,#2)\fi
  172.     \gdef\x@one{#1} \gdef\y@one{#2}
  173.  \fi
  174. \fi}
  175. %----------------------------------------------------------------------
  176. \newdimen\@dotgap
  177. \newdimen\@ddotgap
  178. \newcount\@x@diff
  179. \newcount\@y@diff
  180. \newdimen